//
//  MainPageViewController.m
//  BTRIP
//
//  Created by johnbk on 15/11/12.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "MainPageViewController.h"
#import "AppDelegate.h"
#define vBackBarButtonItemName  @"backArrow.png"    //导航条返回默认图片名
@interface MainPageViewController ()

@end

@implementation MainPageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
	
	self.title = @"主界面";
	self.view.backgroundColor = [UIColor greenColor];
	
	UIButton *menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	menuBtn.frame = CGRectMake(0, 0, 20, 18);
	[menuBtn setBackgroundImage:[UIImage imageNamed:@"iconfont-mulu"] forState:UIControlStateNormal];
	[menuBtn addTarget:self action:@selector(openOrCloseLeftList) forControlEvents:UIControlEventTouchUpInside];
	self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:menuBtn];
}
- (void) openOrCloseLeftList
{
	AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
	
	if (tempAppDelegate.leftSlideVC.closed)
	{
		[tempAppDelegate.leftSlideVC openLeftView];
	}
	else
	{
		[tempAppDelegate.leftSlideVC closeLeftView];
	}
}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
	NSLog(@"viewWillDisappear");
	AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
	[tempAppDelegate.leftSlideVC setPanEnabled:NO];
}

- (void)viewWillAppear:(BOOL)animated
{
	[super viewWillAppear:animated];
	NSLog(@"viewWillAppear");
	AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
	[tempAppDelegate.leftSlideVC setPanEnabled:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
